<?php

/**
 * @Desc:账户加减值 实体
 * @author dasheng@baofu.com(大圣)
 * @datetime 2025/4/6 21:16
 */

namespace App\baocaitong3\Entity;

class ValuesActionEntity implements \JsonSerializable
{
    public $version;
    public $transSerialNo;
    public $reqTime;
    public $platformNo;
    public $transOrderNo;
    public $orderNo;
    public $feeMemberId;
    public $accountType;
    public $dealAmount;
    public $orderType;
    public $acctInfo = [];

    public function jsonSerialize()
    {
        return array_filter((array)$this, function($v) {
            return $v !== null;
        });
        // TODO: Implement jsonSerialize() method.
    }

    // 统计金额
    public function dealAmountAct()
    {
        try {
            if ($this->acctInfo == null) throw new \Exception("参数异常，参数为空");
            if(!is_array($this->acctInfo)) throw new \Exception("参数异常[acctInfo]须为数组");
            $this->dealAmount = 0;
            foreach ($this->acctInfo as $item)
            {
                $this->dealAmount += $item->transAmount;
            }
        }catch (\Exception $ex){
            $this->dealAmount = 0;
        }
    }
}